package com.chess.plugin;

import com.chess.constant.AppConstant;
import com.chess.echo.EchoServer;
import com.sojoys.artifact.core.IPlugin;
import com.sojoys.artifact.manager.PropManager;

/**
 * @author : DengYing
 * @CreateDate : 2017年4月21日 下午5:32:18
 * @Description ：Please describe this document
 */
public class NettyPlugin implements IPlugin {
	EchoServer echoServer = null;
	@Override
	public boolean start() {
		echoServer = new EchoServer();
		String host = PropManager.get(AppConstant.NETTY_HOST);
		int port = PropManager.getInt(AppConstant.NETTY_PORT);
		try {
			echoServer.bind(host, port, false);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

	@Override
	public boolean stop() {
		if (echoServer!=null) {
			echoServer.shutdown();
			return true;
		}
		return false;
	}

}
